package com.ruoyi.common.core.domain;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

/**
 * @author tianl
 * @date 2023/4/27
 * @description:
 */
@Data
public class BasePageReq<T> {
    private Integer pageNo = 1;
    private Integer pageSize = 20;

    /**
     * 获取mybatis分页对象
     *
     * @return
     */
    public Page<T> page() {
        return new Page<>(this.pageNo, this.pageSize);
    }

    public Page<T> pageNoOptimize() {
        //复杂sql时，分页插件开启sql优化会提示异常:optimize this sql to a count sql has exception
        Page page = new Page<>(this.pageNo, this.pageSize);
        page.setOptimizeCountSql(false);
        return page;
    }
}